package com.yykj.common.service;

import org.springframework.data.redis.core.ZSetOperations;

import java.util.Set;

/**
 * Created by chendg on 2018/1/9 0009.
 */
public interface RedisService {

	String getKeyLock(String key);

	boolean lock(String key, String value);

	void unlock(String key, String value);

	String get(String key);

	String formatKey(String key);

	void set(String key, String value);

	void set(String key, String value, long seconds);

	void expire(String key, long expire);

	void reset(String key);

	void removeAllKeysLike(String prefix);

	void remove(String s);

	void setPojo(String key, Object object, long expire);

	<T> T getPojo(String key, Class clazz);

	/**
	 * 添加zset类型并设置分数值
	 * @param key
	 * @param valus
	 * @param score
	 */
	void addZsetIncrementScore(String key,String valus,Integer score);

	/**
	 * 倒序获取 value 值
	 * @param key
	 * @param start
	 * @param end
	 * @return
	 */
	Set<String> reverseRange(String key, long start , long end);


	/**
	 * 获取指定下标的 value ,score 数据
	 * @param key
	 * @param start
	 * @param end
	 */
	Set<ZSetOperations.TypedTuple<String>> rangeWithScores(String key, long start , long end);
}
